package com.me.modules.incident.service.impl;

import com.me.modules.common.common.Constant;
import com.me.modules.common.page.Page;
import com.me.modules.common.page.PageHelper;
import com.me.modules.common.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.me.modules.incident.dao.IncidentInfoDao;
import com.me.modules.incident.entity.IncidentInfoEntity;
import com.me.modules.incident.service.IncidentInfoService;



@Service("incidentInfoService")
public class IncidentInfoServiceImpl implements IncidentInfoService {
	@Autowired
	private IncidentInfoDao incidentInfoDao;

	@Override
	public IncidentInfoEntity queryObject(Long id){
		return incidentInfoDao.queryObject(id);
	}

	@Override
	public List<IncidentInfoEntity> queryList(Map<String, Object> map){
		return incidentInfoDao.queryList(map);
	}

    @Override
    public List<IncidentInfoEntity> queryListByBean(IncidentInfoEntity entity) {
        return incidentInfoDao.queryListByBean(entity);
    }

	@Override
	public int queryTotal(Map<String, Object> map){
		return incidentInfoDao.queryTotal(map);
	}

	@Override
	public int save(IncidentInfoEntity incidentInfo){
		incidentInfo.setStatus("1");
		incidentInfo.setIncCreateDate(new Date());
		incidentInfo.setReqId(UserUtils.getCurrentUserId());

		return incidentInfoDao.save(incidentInfo);
	}

	@Override
	public int update(IncidentInfoEntity incidentInfo){
        return incidentInfoDao.update(incidentInfo);
	}

	@Override
	public int delete(Long id){
        return incidentInfoDao.delete(id);
	}

	@Override
	public int deleteBatch(Long[] ids){
        return incidentInfoDao.deleteBatch(ids);
	}


	@Override
	public Page<IncidentInfoEntity> findPage(IncidentInfoEntity incidentInfo, int pageNum) {
		PageHelper.startPage(pageNum, Constant.pageSize);
		incidentInfoDao.queryList(incidentInfo);
		return PageHelper.endPage();
	}
}
